package com.mall.pay.constant;

public enum PayRetCode {
    // 系统公用
    SUCCESS("000000", "支付宝预下单成功"),

    REQUISITE_PARAMETER_NOT_EXIST("000001", "必要的参数不能为空"),

    FAIL("000002", "支付宝预下单失败"),

    SYSTEM_UNKNOWN("0000003", "系统异常，预下单状态未知!!!"),

    SYSTEM_ERROR("005099", "系统错误"),

    UNSUPPORTED_TYPE_TRADE("0000004", "不支持的交易状态，交易返回异常!!!"),

    SUCCESS_PAY("000100", "查询返回该订单支付成功");

    private String code;
    private String message;

    PayRetCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * Getter method for property <tt>code</tt>.
     *
     * @return property value of code
     */
    public String getCode() {
        return code;
    }

    /**
     * Setter method for property <tt>code</tt>.
     *
     * @param code value to be assigned to property code
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * Getter method for property <tt>message</tt>.
     *
     * @return property value of message
     */
    public String getMessage() {
        return message;
    }

    /**
     * Setter method for property <tt>message</tt>.
     *
     * @param message value to be assigned to property message
     */
    public void setMessage(String message) {
        this.message = message;
    }

    public static String getMessage(String code) {
        for (PayRetCode s : PayRetCode.values()) {
            if (null == code)
                break;
            if (s.code.equals(code)) {
                return s.message;
            }
        }
        return null;
    }
}
